/**
 * *************************************
 * Copyright(c)2016 Dingdang Yixia 
 * All Rights Reserved.
 *
 * @File: BonusServiceImpl.java
 * @Package: com.ddyx.service.impl
 * @Description:
 * 
 * @Version: V1.0
 * @Author: Yidong.Xiang
 * @Date: 2017年12月7日 下午9:16:40
 * 
 * *************************************
 */
package com.ddyx.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ddyx.entity.CampaignBonus;
import com.ddyx.mapper.WxUserBonusMapper;
import com.ddyx.service.IWxUserBonusService;
import com.ddyx.util.MyBeanUtils;
import com.ddyx.util.RequestForm;
import com.ddyx.util.ResponseForm;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: WxUserBonusServiceImpl.java
 * @Module: 
 * @Description: 
 * 
 * @author: Yidong.Xiang
 * @date: 2017年12月7日 下午9:16:40
 * 
 */
@Slf4j
@Service
public class WxUserBonusServiceImpl implements IWxUserBonusService {

	@Resource
	WxUserBonusMapper wxUserBonusMapper;
	@Override
	public ResponseForm findMyBonus(RequestForm param) {
		ResponseForm result = new ResponseForm();
		CampaignBonus bonus = new CampaignBonus();
		@SuppressWarnings("unchecked")
		Map<String, Object> paramMap = (Map<String, Object>) param.getData();
		try {
			MyBeanUtils.populate(bonus, paramMap);
			List<CampaignBonus> list = wxUserBonusMapper.select(bonus);
			result.setData(list);
			if(list!=null) {
				result.setTotal(list.size());
			}else
				result.setTotal(0);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			result.setStatus(false);
			result.setMessage("操作有误");
			log.error("操作有误");
		}
		return result;
	}

	@Override
	public ResponseForm findCampInstanceBonus(RequestForm param) {
		ResponseForm result = new ResponseForm();
//		FriendBonus bonus = new FriendBonus();
		@SuppressWarnings("unchecked")
		Map<String, Object> paramMap = (Map<String, Object>) param.getData();
		try {
//			MyBeanUtils.populate(bonus, paramMap);
//			List<FriendBonus> list = wxFriendBonusMapper.select(bonus);
			List<Map<String, Object>> list = wxUserBonusMapper.findFriendBonus(paramMap);
			result.setData(list);
			if(list!=null) {
				result.setTotal(list.size());
			}else
				result.setTotal(0);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			result.setStatus(false);
			result.setMessage("操作有误");
			log.error("操作有误");
		}
		return result;
	}
}
